/**
 * 
 */
package server;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

import com.XSQS.storage.manager.DocManager;
import com.XSQS.xmlQueryEngine.ResultList;
import com.XSQS.xmlQueryEngine.XQEngine;
import com.XSQS.xmlQueryEngine.exceptions.InvalidQueryException;

/**
 * @author Administrator
 *
 */
public class Test3
{

    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws InvalidQueryException, IOException
    {
	XQEngine engine = new com.XSQS.xmlQueryEngine.XQEngine();
	engine.setMinIndexableWordLength(0);
	engine.setShowFileIndexing(true);
	engine.setUseLexicalPrefixes(true);
	engine.setIndexer();

	String query1 = "/books";
	ResultList result1 = null;
	result1 = engine.setQuery(query1);
	System.out.println(result1.getNumTotalItems());
	System.out.println(result1 == null);
//	
//	List list = new LinkedList();
//	int count = rl.getNumTotalItems();
//	for (int i = 1; i <=count; ++i)
//	{
//	    list.add(rl.subscript(i).emitXml());
//	}
//	System.out.println(list.toString());
//	ResultList resultList = null;
//	System.out.println(resultList.getNumTotalItems());
	
	//String str = rl.emitXml();
	//rl.setNumValidItems(5);
	//ResultList rl2 = rl.string_value(true);
//	String str = rl.subscript(24).emitXml();
//	System.out.println(rl.getNumDocuments());
//	System.out.println(rl.getNumTotalItems());
//	System.out.println(rl.getNumValidItems());
//	System.out.println(str);
//	String str2 = rl.getAST().toString("");
//	System.out.println(str2);
	
//	int id = engine.getIndexManager().getStorageManager().getQueryInterface().getID("book1.xml");
//	System.out.println("docID = " + id);
//	engine.getIndexManager().getStorageManager().getQueryInterface().deleteDoc(1);
//	engine.getIndexManager().getStorageManager().save();
	
	
//	File file = new File("test/book.xml");
//	FileInputStream fis = new FileInputStream(file);
//	byte[] fileByte = new byte[fis.available()];
//	fis.read(fileByte);
//	System.out.println(new String(fileByte));
//	System.out.println("Finish!!");
//	String str = "33";
//	System.out.println(Integer.valueOf(str));
	engine.getIndexManager().getStorageManager().exit();
	System.out.println("Finish");

    }
    

}
